{% extends "base.html" %}
{% block title %}Результаты игры{% endblock %}

{% block contentheader %}Результаты{% endblock %}
{% block content %}

<script>
function view_f(s)
{
    // alert(s);
    var ob = document.getElementById(s);
    if (ob.style.display == 'none')
    {
        ob.style.display='block';
    }
    else
    {
        ob.style.display='none';
    }
}
</script>

{% if wrong_pin %}
<h1> Неверный pin-код </h1>
{% endif %}
{% if admin %}
<strong> Неиспользованные слова: </strong>
{% for word in unused_words %}
{{word.text}},
{% endfor %}
{{last_unused_word.text}}
{% endif %}
<br/>
{% if paired %}
<table border>
<tr> <td> <strong> Игрок </strong> </td> <td> <strong> Объяснил </strong> </td> <td> <strong> Угадал </strong> </td> <td> <strong> Всего </strong> </td> </tr>
{% for pair in pairs %}
<tr> <td> {{pair.player_1}} </td> <td> {{pair.first_explained}} <br/>
<!--- List of explained words -->
<button onClick='view_f("{{pair.pair_id}}1")'> Слова </button>
<div id="{{pair.pair_id}}1" style="display:none">
{% for word in pair.first_explained_words %}
{{word}} <br>
{% endfor %}
</div>
<!--- // List of explained words -->
</td> <td> {{pair.first_guessed}} </td> <td rowspan=2> {{pair.sum}} </td> </tr>
<tr> <td> {{pair.player_2}} </td> <td> {{pair.first_guessed}} <br/>
<!--- List of explained words -->
<button onClick='view_f("{{pair.pair_id}}2")'> Слова </button>
<div id="{{pair.pair_id}}2" style="display:none">
{% for word in pair.second_explained_words %}
{{word}} <br>
{% endfor %}
</div>
<!--- // List of explained words --> 
</td> <td> {{pair.first_explained}} </td> <td rowspan=2> </td> </tr>
{% endfor %}
<!---
Формат указания игроков
<tr> <td> Player1 </td> <td> 1 </td> <td> 3 </td> <td rowspan=2> 4 </td> </tr>
<tr> <td> Player2 </td> <td> 3 </td> <td> 1 </td> <td> </td> </tr>
-->

{% else %}
<table border>
<tr> <td> <strong> Игрок </strong> </td> <td> <strong> Объяснил </strong> </td> <td> <strong> Угадал </strong> </td> <td> <strong> Всего </strong> </td> </tr>
{% for player in singles %}

<tr> <td> {{player}} </td> <td> {{singles[player].explained}} <br>
<!--- List of explained words -->

<button onClick='view_f("{{singles[player].id}}1")'> Слова </button>
<div id="{{singles[player].id}}1" style="display:none">
{% for word in singles[player].explained_words %}
{{word}} <br>
{% endfor %}
</div>

<!--- // List of explained words -->
</td> <td> {{singles[player].guessed}} <br>
<!--- List of guessed words -->

<button onClick='view_f("{{singles[player].id}}2")'> Слова </button>
<div id="{{singles[player].id}}2" style="display:none">
{% for word in singles[player].guessed_words %}
{{word}} <br> 
{% endfor %}
</div>

<!--- // List of guessed words -->
</td> <td> {{singles[player].explained + singles[player].guessed}} </td> </tr>

{% endfor %}
</table>
{% endif %}


{% endblock %}
